<%@page contentType="text/html;charset=utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%--
  Created by IntelliJ IDEA.
  User: wwj
  Date: 2020/8/2
  Time: 9:25
  To change this template use File | Settings | File Templates.
--%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/style.css"/>
    <script src="${pageContext.request.contextPath}/layui/jquery-3.4.1.js"></script>

    <script type="text/javascript" src="https://cdn.goeasy.io/goeasy-1.0.17.js"></script>

    <title>商品管理</title>
    <style type="text/css">
        th {
            text-align: center;
        }
    </style>
    <script>
        function qiangsha(id) {
            $.ajax({
                url:"${pageContext.request.contextPath}/product/updateProduct",
                data:"pid="+id,
                dataType:"json",
                type:"post",
            })
        }
    </script>


    <script type="text/javascript">
        var goEasy = new GoEasy({
            host:'hangzhou.goeasy.io',//应用所在的区域地址，杭州：hangzhou.goeasy.io，新加坡：singapore.goeasy.io
            appkey: "BC-45150c1639b04b0388a60611724f1005",//替换为您的应用appkey
            forceTLS:false, //如果需要使用HTTPS/WSS，请设置为true，默认为false
            onConnected: function() {
                console.log('连接成功！')
            },
            onDisconnected: function() {
                console.log('连接断开！')
            },
            onConnectFailed: function(error) {
                console.log('连接失败或错误！')
            }
        });

        goEasy.subscribe({
            channel: "my_channel1", //替换为您自己的channel
            onMessage: function (message) {
                alert(message.content);
            }
        });

    </script>


</head>
<body>

<div class="container">

    <div class="row">
        <div class="col-md-12" style="height: 100px;">
            <h1 class="text-center text-danger">秒杀专区</h1>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12" style="text-align: center;">
            <form action="#">
                <table class="table table-bordered table-hover">
                    <thead>
                    <tr class="btn-primary">
                        <th>商品编号</th>
                        <th>商品名称</th>
                        <th>商品描述</th>
                        <th>商品数量</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>

                    <c:forEach items="${requestScope.selectAllProduct }"  var="product">
                    <tr>
                        <td>${product.pid}</td>
                        <td>${product.descriptiion}</td>
                        <td>${product.pname}</td>s
                        <td>
                            <span class="label label-primary">${product.account}</span>
                        </td>
                        <td>
                            <a href="#" class="btn btn-xs btn-danger" onclick="qiangsha(${product.pid})">秒杀<span class="czs-web-edit"></span></a>
                        </td>
                    </tr>
                    </c:forEach>


                    </tbody>
                </table>
            </form>
        </div>
    </div>
</div>

</body>
</html>